package com.qding.park.manager.common.pojo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageInfo;

/**
 * @ClassName ParkDataResult
 * @Description TODO(车场rest 接口自定义响应报文 data部份)
 * @author Administrator
 * @Date 2016年8月23日 下午2:42:34
 * @version 1.0.0
 */
public class ParkDataResult {
	private static final String LIST_TAG = "list";

	/**
	 * @Field @data : TODO(存放数据的map)
	 */
	private Map<String, Object> data = new HashMap<String, Object>();

	/**
	 * @Description (向datalist 加入列表)
	 * @param list
	 */
	public void putDataOnList(List list) {

		List datalist = (List) data.get(LIST_TAG);

		datalist.addAll(list);
	}

	
	public static ParkDataResult createEmpty(){
		ParkDataResult data=new ParkDataResult();
		
		return data;
	}
	/**
	 * @Description (向datalist 加入单个对象)
	 * @param map
	 */
	public void putDataOnList(Map map) {

		List datalist = (List) data.get(LIST_TAG);

		datalist.add(map);
	}

	/**
	 * @Description (创建list DATA区域)
	 * @return
	 */
	public static ParkDataResult createListDate() {
		ParkDataResult data = new ParkDataResult();

		data.getData().put(LIST_TAG, new ArrayList<Map<String, Object>>());

		return data;

	}
	
	public static ParkDataResult createListDate(Object list,PageInfo page ) {
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("list",list);
		data.put("currentPage", page.getPageNum());
		data.put("numPerPage", page.getPageSize());
		data.put("totalCount", page.getTotal());
		data.put("hast", page.isHasPreviousPage());
		data.put("next", page.isHasNextPage());
		
		ParkDataResult parkDataResult=ParkDataResult.createObjDate();
		parkDataResult.putMapOnObj(data);
		return parkDataResult;
	}

	/**
	 * @Description (创建obj类型数据)
	 * @return
	 */
	public static ParkDataResult createObjDate() {
		ParkDataResult dataResult = new ParkDataResult();
		
		return dataResult;

	}
	
	public  void putDataOnObj(String key,Object value){
		data.put(key, value);
	}
	
	public  void putMapOnObj(Map map){
		data.putAll(map);
	}

	public Map<String, Object> getData() {
		return data;
	}

}
